/**
 * 
 */
package com.base.myproject.client.busi.service;

import java.util.ArrayList;
import java.util.List;

import com.base.myproject.client.busi.BaseStore;
import com.base.myproject.client.busi.BO.BusiObject;
import com.base.myproject.client.jdbc.StoreInfo;
import com.base.myproject.client.ui.BaseGrid;
import com.base.myproject.client.ui.BaseJDBCPanel;
import com.base.myproject.client.ui.celleditor.BaseSimpleCombox;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.layout.FillLayout;

/**
 * 公司信息设置
 * @author zgw
 *2009-11-20 下午02:17:17
 * javazgw@gmail.com
 */
public class Systempanel extends BaseJDBCPanel{
	BaseStore<BusiObject> itemstore ;
	BaseGrid<BusiObject> 	s_service_item_grid;
	
	public Systempanel()
	{
		super();
		init();
	}
	
	protected void init()
	{
		
		this.setWidth("1000px");
		
		this.setAutoHeight(true);
		
		
		this.add(initWeiget());
		registerMainStore(itemstore);
		registerStore(itemstore);
	}
	public ContentPanel initWeiget()
	{
		ContentPanel cpanel = new ContentPanel();
		cpanel.setHeading("公司/部门信息录入");
		CreateServiceItemStore();
		CreateServiceItemGrid();
		cpanel.setLayout(new FillLayout());
		cpanel.add(s_service_item_grid);
		cpanel.setHeight("450");
		return cpanel;
		
	}
	void CreateServiceItemStore(){
		
		ModelType type = new ModelType();
		type.setRoot("records");
		type.setRecordName("record");
		type.setTotalName("totle");
		type.addField("icode");
		type.addField("id");
		type.addField("name");
		type.addField("title");
		type.addField("tel");
		type.addField("fax");
		type.addField("printmessage");
		type.addField("upsystemid");
		
		type.addField("addr");
		type.addField("enName");
		type.addField("slogan");
		type.addField("Zip");
		type.addField("assessmentmethod");
		
		// type.addField("Phone");
		// type.addField("imagepath");
		StoreInfo info = new StoreInfo();
		info.setTablename("SystemInfo");
		info.setSql("select * from SystemInfo order by id asc");
		info.setKeyname(new String[] { "icode" });
		info.setForcenolimit("true");
		
		itemstore = new BaseStore<BusiObject>(type,info);

	
	}
	void CreateServiceItemGrid()
	{
		CheckBoxSelectionModel cbs = new CheckBoxSelectionModel();
		List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
		columns.add(cbs.getColumn());
		
		
		ColumnConfig c1 = new ColumnConfig("id", "id号",80);
		TextField<String> c1t = new TextField<String>();
		c1.setEditor(new CellEditor(c1t));
		
		ColumnConfig c2 = new ColumnConfig("name", "公司/部门名称", 150);
		TextField<String> c2t = new TextField<String>();
		c2.setEditor(new CellEditor(c2t));
		
		ColumnConfig c3 = new ColumnConfig("title", "简称", 100);
		TextField<String> c3t = new TextField<String>();
		c3.setEditor(new CellEditor(c3t));
		
		ColumnConfig c8 = new ColumnConfig("enName", "英文名称", 100);
		TextField<String> c8t = new TextField<String>();
		c8.setEditor(new CellEditor(c8t));
		
		ColumnConfig c4 = new ColumnConfig("tel", "电话", 120);
		TextField<String> c4t = new TextField<String>();
		c4.setEditor(new CellEditor(c4t));
		
		ColumnConfig c5 = new ColumnConfig("fax", "传真", 120);
		TextField<String> c5t = new TextField<String>();
		c5.setEditor(new CellEditor(c5t));
		
		ColumnConfig c6 = new ColumnConfig("printmessage", "打印信息", 120);
		TextField<String> c6t = new TextField<String>();
		c6.setEditor(new CellEditor(c6t));
		
		ColumnConfig c7 = new ColumnConfig("upsystemid", "上级公司id号",100);
		TextField<String> c7t = new TextField<String>();
		c7.setEditor(new CellEditor(c7t));
		
		columns.add(c1);
		columns.add(c2);
		columns.add(c8);
		columns.add(c3);
		columns.add(c4);
		columns.add(c5);
		columns.add(c6);
		columns.add(c7);
		
		ColumnModel cm = new ColumnModel(columns);
		 s_service_item_grid = new BaseGrid<BusiObject>(itemstore, cm);
		 cbs.setSelectionMode(SelectionMode.SINGLE);
		 s_service_item_grid.setSelectionModel(cbs);
		 s_service_item_grid.setHeight("450");
		 s_service_item_grid.getView().setForceFit(true);
	}
}
